package com.tvein.sanguo.action.controller.role
{
	//flash
	//pureMVC
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.utilities.fabrication.patterns.command.SimpleFabricationCommand;
	//custom
	import com.tvein.sanguo.action.common.GameConstants;
//
	public class RoleCommand extends SimpleFabricationCommand implements ICommand
	{
		override public function execute(notification:INotification) : void
		{
			switch(notification.getBody()[0])
			{
				case "-showBox":
					sendNotification(GameConstants.ACTION_ROLE, notification.getBody()[1]);
					break;
				case "-roleLogin":
					routeNotification(GameConstants.GAME_CONSOLE, notification.getBody(), null, "*");
					break;
				case "-roleList":
					routeNotification(GameConstants.GAME_CONSOLE, notification.getBody(), null, "*");
					break;
				case "-roleCreate":
					routeNotification(GameConstants.GAME_CONSOLE, notification.getBody(), null, "*");
					break;
				case "-roleDelete":
					routeNotification(GameConstants.GAME_CONSOLE, notification.getBody(), null, "*");
					break;
				case "-roleDetail":
					routeNotification(GameConstants.GAME_CONSOLE, ["-roleStatus", ["roleDetail"]], null, "*");
					break;
				case "-roleGoods":
					routeNotification(GameConstants.GAME_CONSOLE, ["-roleStatus", ["roleGoods"]], null, "*");
					break;	
				case "-roleItem":
					routeNotification(GameConstants.GAME_CONSOLE, ["-roleStatus", ["roleItem"]], null, "*");
					break;
				case "-roleSkill":
					routeNotification(GameConstants.GAME_CONSOLE, ["-roleStatus", ["roleSkill"]], null, "*");
					break;
				case "-roleArmy":
					routeNotification(GameConstants.GAME_CONSOLE, ["-roleStatus", ["roleArmy"]], null, "*");
					break;
				case "-item":
					var itemID:int = notification.getBody()[1][1];
					
					switch(notification.getBody()[1][0])
					{
						case "itemDrop":
							routeNotification(GameConstants.GAME_CONSOLE, ["-gameCommand", ["ItemCall(" + itemID + ",ItemDrop,);"]], null, "*");
							sendNotification(GameConstants.ACTION_ROLE, ["roleItem"]);
							break;
						case "itemUnload":
							routeNotification(GameConstants.GAME_CONSOLE, ["-gameCommand", ["ItemCall(" + itemID + ",ItemUnload,);"]], null, "*");
							sendNotification(GameConstants.ACTION_ROLE, ["roleItem"]);
							break;
						case "itemLoad":
							routeNotification(GameConstants.GAME_CONSOLE, ["-gameCommand", ["ItemCall(" + itemID + ",ItemLoad,);"]], null, "*");
							sendNotification(GameConstants.ACTION_ROLE, ["roleItem"]);
							break;
						case "itemUse":
							sendNotification(GameConstants.ACTION_CLOSE, "*");
							routeNotification(GameConstants.GAME_CONSOLE, ["-gameCommand", ["ItemCall(" + itemID + ",ItemUse,);"]], null, "*");
							break;
					}
					
					break;
				case "-gameCommand":
					routeNotification(GameConstants.GAME_CONSOLE, ["-gameCommand", notification.getBody()[1]], null, "*");
					break;
				case "-close":
					sendNotification(GameConstants.ACTION_CLOSE, notification.getBody()[1]);
					break;
			}
		}
	}
}